package com.linksky.thread;

import com.linksky.crawler.Crawler;
import com.linksky.entity.PlayList;

import java.util.ArrayList;
import java.util.List;

public class NewPlayListCrawlerThread extends Thread {

    private int pageNum;
    private Crawler crawler;

    public NewPlayListCrawlerThread(Crawler crawler) {
        this.crawler = crawler;
    }

    @Override
    public void run() {
        while (!isInterrupted()) {
            System.out.println("++++++++Add new playlist start++++++++++");
            List<PlayList> list = new ArrayList<>();
            for (pageNum = 0; pageNum <100; pageNum++) {
                System.out.print(pageNum + ";");
                list.addAll(Crawler.crawlNewPlayList(pageNum));
            }
            crawler.addNewPlayList(list);
            System.out.println("+++++++Add new playlist end+++++++");
        }
    }
}
